const q = (css, p = document) => p.querySelector(css);
const evl = q('#mvList');

chrome.runtime.sendMessage({id:'getState'}, function(enabled) {
    q('#power>input').checked = enabled;
});

chrome.tabs.query({ currentWindow: true, active: true }, function(tabs) {
	if (tabs[0].url.startsWith('http')) {
		// console.dir(tabs[0])
		chrome.runtime.sendMessage({id:'getMVCount', tabId: tabs[0].id}, function(n) {
			if (!n) return;
			evl.href = './mvList.html';
			evl.textContent = '已捕获媒体数: '+ n;
		});
	}
});

q('#power').addEventListener('click', ev => {
    chrome.runtime.sendMessage({id:'power'});
    window.close();
});